<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<html>
<head>
<title>Flex Object Messaging through LCDS FABridge</title>
<style>
body { margin: 10px;
 overflow:hidden }

textarea {
	font-size: 1em;
}
</style>
<script type="text/javascript" src="../includes/js/FABridge.js"></script>
<script type="text/javascript" src="../includes/js/FDMSLib.js"></script>

</head>

<p>The page tests sending/recieving a simple Object message through LCDS-FABridge and JMSAdapter using a polling amf channel</p>
<p>Feature tested: 
<li>Producer.send, Producer.setDestination,</li>
<li>Consumer.setDestination, Consumer.subscribe, Consumer.addEventListener;</li>
<li>AsyncMessage.setBody</li>

<body scroll='no' style="font-size:.9em;">
<script language="javascript">
    var p;
    var c;

    function fdmsLibraryReady()
    {        
        log("library ready");
				
		p = new Producer();
        p.setDestination("MyJMSObjectTopic");
        
		c = new Consumer();
        c.setDestination("MyJMSObjectTopic");        
        c.addEventListener("message", messageHandler);				
        c.subscribe();		
    }

    function sendChat()
    {        
       
		var m = new AsyncMessage();
        var body = {a:"abc"};			
        m.setBody(body);
        p.send(m);
		log("Send message: body=" + body + " a=" + body.a);
    }

    function messageHandler(event)
    {
		var body = event.getMessage().getBody();
        log("Received message(" + typeof(body) + "): body=" + body + " a=" + body.a);
    }
   	
	function log(s){
		var myta = document.getElementById("ta");
		myta.appendChild(document.createTextNode(s + "\n" ));
	}

</script>

<script>
    FDMSLibrary.load("../includes/swf/FDMSBridge.swf", fdmsLibraryReady);
</script>

<div style="width:1024px">
<div style="margin-bottom: 20px;float:left;padding: 20px;">
	<button onClick="sendChat();return false;">Send</button>
    <br />
    <textarea name="ta" cols="100" rows="30" id="ta" ></textarea>
</div>
</div>
</body>


</html>
